import click
from flask.cli import AppGroup

from .db.init import init

db_cli = AppGroup("db")


@db_cli.command("init")
@click.option("--force", is_flag=True, help="Create after drop.")
def db_init(force):
    """
    initialize the database.
    """
    print('init db')
    if force:
        click.confirm("此操作将清空数据，是否继续?", abort=True)
    init(force)
    click.echo("数据库初始化成功")
